import java.io.*;

public class test5 {
    public static void main(String[] args) throws IOException {
        method1();
        method2();
        method3();
        method4();
    }

    public static void method1() throws IOException {
        FileInputStream fis = new FileInputStream("Java_11_16\\csb.txt");
        FileOutputStream fos = new FileOutputStream("Java_11_16\\test5.txt");
        int b;
        long startTime = System.currentTimeMillis();
        while ((b = fis.read()) != -1) {
            fos.write(b);
        }
        long endTime = System.currentTimeMillis();
        System.out.println(endTime - startTime);
        fis.close();
        fos.close();
    }

    public static void method2() throws IOException {
        FileInputStream fis = new FileInputStream("Java_11_16\\csb.txt");
        FileOutputStream fos = new FileOutputStream("Java_11_16\\test5.txt");
        int b;
        byte[] chars = new byte[1024 * 8];
        long startTime = System.currentTimeMillis();
        while ((b = fis.read(chars)) != -1) {
            fos.write(chars, 0, b);
        }
        long endTime = System.currentTimeMillis();
        System.out.println(endTime - startTime);
        fis.close();
        fos.close();
    }

    public static void method3() throws IOException {
        BufferedInputStream bis = new BufferedInputStream(new FileInputStream("Java_11_16\\csb.txt"));
        BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream("Java_11_16\\test5.txt"));
        int b;
        long startTime = System.currentTimeMillis();
        while ((b = bis.read()) != -1) {
            bos.write(b);
        }
        long endTime = System.currentTimeMillis();
        System.out.println(endTime - startTime);
        bis.close();
        bos.close();
    }

    public static void method4() throws IOException {
        BufferedInputStream bis = new BufferedInputStream(new FileInputStream("Java_11_16\\csb.txt"));
        BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream("Java_11_16\\test5.txt"));
        int b;
        byte[] chars = new byte[1024 * 8];
        long startTime = System.currentTimeMillis();
        while ((b = bis.read(chars)) != -1) {
            bos.write(chars,0,b);
        }
        long endTime = System.currentTimeMillis();
        System.out.println(endTime - startTime);
        bis.close();
        bos.close();
    }
}
